<template>
    <div class="courseInfo-div">
        <el-form ref="form" :model="form" label-width="80px">
            <el-form-item label="课程名称:">
                <div>
                    <el-input v-model="form.courseName"></el-input>
                </div>
            </el-form-item>
            <el-form-item label="课程号:">
                <div>
                    <el-input v-model="form.courseNumber"></el-input>
                </div>
            </el-form-item>
            <el-form-item label="开设学院:">
                <div>
                    <el-input v-model="form.college"></el-input>
                </div>
            </el-form-item>
            <el-form-item label="开设专业:">
                <div>
                    <el-input v-model="form.major"></el-input>
                </div>
            </el-form-item>
            <el-form-item label="开设年级:">
                <div>

                    <el-input v-model="form.grade"></el-input>
                </div>
            </el-form-item>
            <el-form-item label="学分:">
                <div>
                    <el-input v-model="form.credit"></el-input>
                </div>
            </el-form-item>
            <el-form-item label="课程类别:">
                <div>
                    <el-input v-model="form.classification"></el-input>
                    (专业教育必修,专业教育选修)
                </div>
            </el-form-item>
            <el-form-item label="教师:">
                <div>
                    <el-input v-model="form.teacher"></el-input>
                </div>
            </el-form-item>
            <el-form-item label="上课地点:">
                <div>
                    <el-input v-model="form.location"></el-input>
                </div>
            </el-form-item>
            <el-form-item label="上课时间:">
                <div>
                    <el-input v-model="form.time"></el-input>
                    ("1-3-5"为周一3到5节)
                </div>
            </el-form-item>
            <el-form-item label="上课周期:">
                <div>
                    <el-input v-model="form.period"></el-input>
                    ("1-18"为1到18周)
                </div>
            </el-form-item>
        </el-form>
        <el-button type="primary" @click="addCourse">
            提交
        </el-button>
    </div>
</template>
<script>
export default {
    data() {
        return {
            form: {
                courseName: "",
                courseNumber: 0,
                college: "",
                major: "",
                grade: 0,
                credit: 0,
                classification: "",
                teacher: "",
                location: "",
                time: "",
                period: "",
            }
        }
    },
    methods: {
        addCourse() {
            this.$axios({
                method: "post",
                url: "http://localhost:8000/course/addCourse",
                headers: {
                    AUTHORIZATION: sessionStorage.getItem('access-admin')
                },
                data: {
                    courseName: this.form.courseName,
                    courseNumber: this.form.courseNumber,
                    college: this.form.college,
                    major: this.form.major,
                    grade: this.form.grade,
                    credit: this.form.credit,
                    classification: this.form.classification,
                    teacher: this.form.teacher,
                    location: this.form.location,
                    time: this.form.time,
                    period: this.form.period,
                }
            }).then((res) => {
                console.log(res);
            }).catch(err => {
                console.log(err)
            })
        }
    }
}
</script>

<style lang="scss">
.courseInfo-div {
    .el-input {
        position: relative;
        right: 70px;
        width: 300px;
    }

    div {
        display: flex;
        width: 75%;
    }
}
</style>